﻿using UnityEngine;
using System.Collections;
#if UNITY_EDITOR
using UnityEditor;
#endif

public class testEditor : MonoBehaviour
{
    [SerializeField][HideInInspector]
    protected string str1 = "a";
    protected float int1 = 0;

    public void setStr(string str)
    {
        str1 = str;
    }

    public string getStr()
    {
        return str1;
    }

    void Update()
    {
        if( int1 >= 1f)
        {
            Debug.Log("11111===="+str1);
            int1 = 0f;
        }
        int1 += Time.deltaTime;
    }
}

#if UNITY_EDITOR
[CustomEditor(typeof(testEditor))]
[CanEditMultipleObjects]
public class MyEditor : Editor
{
    
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        serializedObject.Update();
        //得到Test对象
        testEditor test = (testEditor)target;
        //绘制一个窗口
        test.setStr(EditorGUILayout.TextField(new GUIContent("str1"), test.getStr()));


    }
}
#endif
